<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<html>
  <head>
    <title>Department List</title>
	<link href="<s:url value="/css/admin.css"/>" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<s:url value="/js/prototype.js"/>"></script>
  </head>
<script type="text/javascript">

function over(tid)
{
	tid.style.backgroundColor="#EDF1B4";
}

function out(tid)
{
	tid.style.backgroundColor="#ffffff";
}
</script>
  
  <body>
    <br>
    <table width="90%"  border="1" align="center" cellpadding="0" cellspacing="0" style="border-collapse:collapse ">
      <tr align="center">
        <td width="6%" height="25"><strong>No</strong></td>
        <td width="26%"><strong>Code</strong></td>
        <td width="24%"><strong>Name</strong></td>
        <td width="25%"><strong>Telephone</strong></td>
        <td width="19%"><strong>Operation</strong></td>
      </tr>
      <s:iterator value="list" status="i">
      <tr align="center" onMouseOver="over(this);" onMouseOut="out(this)">
        <td height="25"><s:property value="%{#i.index+1}"/> </td>
        <td><s:property value="deptCode"/> </td>
        <td align="center"><s:property value="name"/> </td>
        <td><s:property value="tel"/> </td>
        <td>
        <s:url action="deletedepartment" id="deleteurl">
        	<s:param name="deptCode" value="deptCode"/>
        </s:url>
        <s:url action="initupdatedepartment" id="updateurl">
        	<s:param name="deptCode" value="deptCode"/> 
        </s:url>
        <s:url action="viewdepartment" id="viewurl">
        	<s:param name="deptCode" value="deptCode"/> 
        </s:url>
        <a href="${deleteurl}" onclick="return confirm('All users belong to the depatment will be deleted.\n Are you sure to continue?');">Delete</a>&nbsp;<a href="${updateurl}">Edit</a>&nbsp;<a href="${viewurl}" target="_blank">Details</a></td>
      </tr>
      </s:iterator>
      <s:if test="%{list.size()<10}">
      <s:generator separator="" val="#{''}" count="%{10-list.size()}">
      <s:iterator>
      <tr align="center">
        <td height="25">&nbsp;</td>
        <td>&nbsp;</td>
        <td align="left">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      </s:iterator>
      </s:generator>
      </s:if>
  </table>
  <br>

  <table width="79%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><input type="button" name="Submit" value="Add a new dept" onclick="window.location='<s:url action="initsavedepartment" includeParams="none"/>';"></td>
    <td>&nbsp;</td>
  </tr>
</table>

</body>
</html>
